﻿
using ManagoMes.Read.API.Applications.ProductionScheduling;
using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Jocker;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MangoMes.Write.API.Applications.Login;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.VisualBasic;

namespace ManagoMes.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductionController : ControllerBase
    {


        private readonly IMediator _mediator;

        public ProductionController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 生产任务显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultsDTO<givebirth>> ProductionHtml(ProductionHtmlCommond request, CancellationToken cancellationToken)
        {
            try
            {
                var list =await _mediator.Send(request);

                return list;
            }
            catch (Exception)
            {

                throw;
            }




        }
        /// <summary>
        /// 工作台选择
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<ResultsDTO<WorkStationSto>> WorkStationHtml(WorkStationHtmlCommond request, CancellationToken cancellationToken)
        {

            try
            {
                var list = await _mediator.Send(request);

                return list;
            }
            catch (Exception)
            {

                throw;
            }

        }

        /// <summary>
        /// 工作台数据反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultsDTO<WorkStationSto>> WorkStationback(WorkStationbackCommond request, CancellationToken cancellationToken)
        {

            var list = await _mediator.Send(request);



            return list;


        }

        /// <summary>
        /// 排产选择待优化
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultsDTO<givebirth>> SchedulingDisplay(SchedulingDisplayHtmlCommond request, CancellationToken cancellationToken)
        {

            try
            {
                var list = await _mediator.Send(request);


                return list;

            }
            catch (Exception)
            {

                throw;
            }




        }
        /// <summary>
        /// 生产任务反填
        /// </summary>
        /// <param name="request">
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultsDTO<givebirth>> SchedulingDisplayBack(SchedulingDisplayBackCommond request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _mediator.Send(request);

                return list;
            }
            catch (Exception)
            {

                throw;
            }





        }

        /// <summary>
        /// 转移挑拨单显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultsDTO<DiversionDto>> TransferHtmls(TransferHtmlCommond request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _mediator.Send(request);
                return list;
            }
            catch (Exception)
            {

                throw;
            }




        }

        /// <summary>
        /// 步骤反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultsDTO<ProcessStep>> StepDescriptionBack(StepDescriptionBackCommond request, CancellationToken cancellationToken)
        {

            try
            {
                var list = await _mediator.Send(request);


                return list;
            }
            catch (Exception)
            {

                throw;
            }
           

        }
    }
}
